/*
 * @Description: 工具函数
 * @Author: ls
 * @Date: 2019-09-04 09:10:30
 * @LastEditTime: 2019-10-10 13:52:29
 * @LastEditors: Please set LastEditors
 */
const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}


export const check_login = function(){
  return new Promise((resolve,reject)=>{
    if(!wx.getStorageSync('userInfo').userId){
      // 没有登录的时候reject
      wx.showModal({
        title:'此功能需要登录',
        content:'点击确认前往登录',
        success(res){
          if(res.confirm){
            wx.switchTab({
                url:'/pages/my/main',
                success(){
                  reject(false)
                }
            })
          }else{
            console.log(123)
          }
        }
      })
    }else{
      resolve(true)
    }
  })
  // console.log(1123123)
}


